package org.csu.gp_store.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;

@Data
@TableName("order_item")
public class OrderItem {
    @TableId(value = "indexID",type = IdType.ASSIGN_ID)
    private Long indexID;
    @TableField("itemID")
    private Long itemID;
    @TableField("orderID")
    private Long orderID;
    @TableField("productID")
    private Long productID;
    @TableField("product_name")
    private  String productName;
    @TableField("companyID")
    private Long companyID;
    /**
     * 物流信息
     */
    private String logistics;
    private BigDecimal price;
    private Integer quantity;
    private int status;
    private String  style;
    private String image;
    @TableField(exist = false)
    private Long factoryID;

    public  static OrderItem toOrderItem(Product product, Item item, CartItem cartItem, Orders orders){
        OrderItem orderItem=new OrderItem();
        orderItem.setOrderID(orders.getOrderID());
        orderItem.setItemID(item.getItemID());
        orderItem.setProductID(product.getProductID());
        orderItem.setCompanyID(product.getCompanyID());
        orderItem.setPrice(item.getPrice());
        orderItem.setQuantity(cartItem.getQuantity());
        orderItem.setStyle(item.getStyle());
        orderItem.setProductName(product.getProductName());
        orderItem.setImage(item.getImage());
        return orderItem;
    }
    public  static OrderItem toOrderItem(Product product, Item item, Orders orders, int quantity){
        OrderItem orderItem=new OrderItem();
        orderItem.setOrderID(orders.getOrderID());
        orderItem.setItemID(item.getItemID());
        orderItem.setProductID(product.getProductID());
        orderItem.setCompanyID(product.getCompanyID());
        orderItem.setPrice(item.getPrice());
        orderItem.setQuantity(quantity);
        orderItem.setStyle(item.getStyle());
        orderItem.setProductName(product.getProductName());
        orderItem.setImage(item.getImage());
        return orderItem;
    }
}
